#ifndef __UI_H_LULY_
#define __UI_H_LULY_
// #include <map>
#include "../NinePatch.h"
#include "Font.h"
#include "UIObject.h"
#include "vector_map.h"

class _UI {
 private:
  vector_map<std::string, UIObject*> ui_object_list;
  Font defaultFont;
  NinePatch button_default_ninePatch;
  NinePatch button_hovering_ninePatch;
  NinePatch button_clicked_ninePatch;
  NinePatch panel_60x60_ninePatch;
  NinePatch progressBar_background_ninePatch;
  NinePatch progressBar_front_ninePatch;
  Image checkbox_box_default_image;
  Image checkbox_check_default_image;
  Image checkbox_check_checked_image;

  _UI() {}

  void init();
  void event();
  void update();
  void draw();
  void drawArea(const Rect& area);
  friend class _Luly;
  friend class Button;
  friend class Panel;
  friend class CheckBox;
  friend class ProgressBar;
  friend class VProgressBar;

 public:
  static _UI& getInstance() {
    static _UI instance;
    return instance;
  }

 public:
  //添加UI物体
  //注意，UIObject*必须是指向堆空间的，因为所有UIObject*的释放都是框架内部实现的。
  //如需手动释放，请释放后将该指针置为nullptr
  //添加UIObject
  //所添加的UIObject请务必是通过new创建的
  //因为_UI析构时是会将全部的UIObject都delete掉的（如果不是用new创建，那么delete会导致错误)
  //当然，如果没有进行addUIObject，object是不能被delete掉的
  void addUIObject(UIObject* ui_object);
  void setDefaultFont(Font font);
  Font getDefaultFont();
  ~_UI();
};

#endif
